﻿using AutoMapper;
using B.S.Filtration.Write.Api.Application.Command.CustomerPhoneCommand;
using MediatR;
using B.S.Filtration.ErrorCode;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using B.S.Filtration.Write.Api.Application.Command.ContactPhoneCommand;

namespace B.S.Filtration.Write.Api.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class CustomerPhoneController : ControllerBase
    {
        private readonly IMediator mediator;

        public CustomerPhoneController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 添加客户信息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<int>> CreateCustomerPhone(CreateCustomerPhoneCommand request)
        {
            return await mediator.Send(request);
        }

        /// <summary>
        /// 删除客户信息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<int>> DelCustomerPhone(DelCustomerPhoneCommand request)
        {
            return await mediator.Send(request);
        }

        /// <summary>
        /// 修改客户信息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<int>> UpdCustomerPhone(UpdCustomerPhoneCommand request)
        {
            return await mediator.Send(request);
        }

        /// <summary>
        /// 添加联系人
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<int>> CreateContactPhone(CreateContactPhoneCommand request)
        {
            return await mediator.Send(request);
        }

        /// <summary>
        /// 删除联系人
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<int>> DelContactPhone(DelContactPhoneCommand request)
        {
            return await mediator.Send(request);
        }

        /// <summary>
        /// 修改联系人
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<int>> UpdContactPhone(UpdContactPhoneCommand request)
        {
            return await mediator.Send(request);
        }
    }
}
